//
// Created by mazaiting on 2024/4/27.
//


#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

void Disp(vector<int> &myv)               //输出vector的元素
{
    vector<int>::iterator it;
    for (it = myv.begin(); it != myv.end(); it++)
        cout << *it << " ";
    cout << endl;
}

int main() {
    int a[] = {2, 1, 5, 4, 3};
    int n = sizeof(a) / sizeof(a[0]);
    vector<int> myv(a, a + n);
    cout << "初始myv:  ";
    Disp(myv);                //输出：2 1 5 4 3
    sort(myv.begin(), myv.end(), less<>());
    cout << "递增排序: ";
    Disp(myv);                //输出：1 2 3 4 5
    sort(myv.begin(), myv.end(), greater<>());
    cout << "递减排序: ";
    Disp(myv);                //输出：5 4 3 2 1
    return 0;
}